﻿#region Copyright 
/*-------------------------------------------------------------------------
* 命名空间名称/文件名:    SSPivot.Pay/ServiceCollectionExtensions 
* CLR版本:     4.0.30319.42000
* 机器名称:    DESKTOP-NHMLO8A
* 功 能：       N/A
* 类 名：       ServiceCollectionExtensions
* 创建时间：  2025/5/23 17:01:05
* 版本号：      v1.0
* 创建人:        xulong
*-------------------------------------------------------------------------*/
#endregion 
using Essensoft.Paylink.Alipay;
using Essensoft.Paylink.WeChatPay;
using Microsoft.AspNetCore.Builder;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using SSPivot.Common.Helpers;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Microsoft.Extensions.DependencyInjection
{
    public static class ServiceCollectionExtensions
    {
        public static IServiceCollection AddSSPivotPay(this IServiceCollection services, IConfiguration configuration)
        {
            var isPayEnabled = configuration.GetSection("AppSettings").GetValue<bool>("PayEnabled",false); // ConfigHelper.GetAppSettingBoolean("PayEnabled");
            if (!isPayEnabled) return services;
            // 在 appsettings.json 中 配置选项
            services.Configure<WeChatPayOptions>(configuration.GetSection("WeChatPay"));
            services.Configure<AlipayOptions>(configuration.GetSection("Alipay"));
            // 引入Payment 依赖注入(支付宝支付/微信支付) 
            services.AddAlipay();
            services.AddWeChatPay();
            return services;
        }
    }
}
